#include <iostream>
#include <cmath>
using namespace std;
#define int long long
signed main() {
    string a, b;
    cin >> a >> b;
    int ans = 0;
    for(int i = 0; i < a.size() - 1; i++) {
        for(int j = 1; j < b.size(); j++) {
            if(a[i] == b[j] && a[i + 1] == b[j - 1]) {
                ans++;
            }
        }
    }
    cout << (long long)pow(2, ans);
    return 0;
}